{include file='Public/header' /}
<div class="layui-layout layui-layout-admin">
{include file='Public/head' /}	
{include file='Public/side' /}	
	<div class="layui-body"> 
{include file='Public/crumbs' /}
		<!-- 内容主体区域 -->
		<div class="shu-body">
			<div class="layui-fluid">
				<form class="layui-form layui-form-pane" action="" method="post">
				<input type="hidden" name="id" id="id"  value="{notempty name='link'}{$link['id']}{/notempty}">
				
				<div class="layui-form-item">
				  	<label class="layui-form-label">标题</label>
				  	<div class="layui-input-inline">
						<input type="text" name="title" id="title" placeholder="标题" class="layui-input" value="{notempty name='link'}{$link['title']}{/notempty}" required  lay-verify="required" autocomplete="off">
				  	</div>
					<div class="layui-form-mid layui-word-aux">标题不能为空</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">分类</label>
				  	<div class="layui-input-inline">
						<select id="classid" name="classid" class="col-xs-10 col-sm-5">
                                    	<option value="1" {if condition="$link.classid eq 1"}selected{/if} >首页幻灯</option>
										<option value="2" {if condition="$link.classid eq 2"}selected{/if} >内页幻灯</option>
						</select>
				  	</div>
					<div class="layui-form-mid layui-word-aux">选择分类</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">链接地址</label>
				  	<div class="layui-input-inline">
					<input type="text" name="url" id="url" placeholder="链接地址" class="layui-input" value="{notempty name='link'}{$link['url']}{/notempty}">
				  	</div>
					<div class="layui-form-mid layui-word-aux">链接地址 一定要加HTTP://</div>
				</div>
				
				<div class="layui-form-item">
				  	<label class="layui-form-label">排序</label>
				  	<div class="layui-input-inline">
					<input type="text" name="o" id="o" placeholder="排序" class="layui-input" value="{notempty name='link'}{$link['o']}{/notempty}">
				  	</div>
					<div class="layui-form-mid layui-word-aux">数字越大越靠前</div>
				</div>

				<div class="layui-form-item">
				  	<label class="layui-form-label" style="height:100px; line-height:80px;">缩略图</label>
				  	<div class="layui-input-inline">
						{notempty name='link'}
						{:UpImage("pic",100,100,$link['pic'])}
						{else /}
						{:UpImage("pic",100,100,null)}
						{/notempty}
				  	</div>
					<div class="layui-form-mid layui-word-aux" style="line-height:80px">仅支持jpg、gif、png、bmp、jpeg，且小于1MB。</div>
				</div>
				 
				
				
				<div class="layui-form-item">
				  <div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				  </div>
				</div>
			  </form>
			</div>
		</div>
		<!-- 内容主体区域 END-->
	</div>
{include file='Public/footer' /}	
<script>
layui.use(['form','layer','laydate'], function(){
	var form = layui.form,jq = layui.jquery,layer=layui.layer,laydate = layui.laydate;
	//日期
	laydate.render({
    	elem: '#t' //指定元素
  	});
	
	form.on('submit(formDemo)', function(data){
		loading = layer.load(2, {
			shade: [0.2,'#000']
		});
		var param = data.field;
		jq.post("{:url('update')}",param,function(data){
			//console.log(data);
			if(data.code == 1){
				layer.close(loading);
				layer.msg(data.msg, {icon: 1, time: 1000}, function(){
					//location.reload();
					location.href=data.url;
				});
			}else{
				layer.close(loading);
				layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			}
		});
	return false;
	});
	
	
	
});
</script>